package se.id.vrapp;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;

public class MapFragment extends Fragment {
	int mNum;
	public static String[] depotNames;
	public final static String DEPOT_ID = "DEPOT_ID";


	/**
	 * Create a new instance of CountingFragment, providing "num" as an
	 * argument.
	 */
	static MapFragment newInstance(int num) {
		MapFragment f = new MapFragment();

		// Supply num input as an argument.
		Bundle args = new Bundle();
		args.putInt("num", num);
		f.setArguments(args);

		return f;
	}

	/**
	 * When creating, retrieve this instance's number from its arguments.
	 */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mNum = getArguments() != null ? getArguments().getInt("num") : 1;
	}

	/**
	 * The Fragment's UI is just a simple text view showing its instance number.
	 */
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {

		View v = inflater.inflate(R.layout.map_view, container, false);
		depotNames = getResources().getStringArray(R.array.planner_depots);

		final Intent intent = new Intent(getActivity(), MapDialogActivity.class);

		ImageButton b1 = (ImageButton) v.findViewById(R.id.imageButton1);
		b1.setOnClickListener(new View.OnClickListener() {
			public void onClick(View view) {
				
				intent.putExtra(DEPOT_ID, 7);
				startActivity(intent);
			}
		});
		ImageButton b2 = (ImageButton) v.findViewById(R.id.imageButton2);
		b2.setOnClickListener(new View.OnClickListener() {
			public void onClick(View view) {
				
				intent.putExtra(DEPOT_ID, 8);
				startActivity(intent);
			}
		});
		ImageButton b3 = (ImageButton) v.findViewById(R.id.imageButton3);
		b3.setOnClickListener(new View.OnClickListener() {
			public void onClick(View view) {
				
				intent.putExtra(DEPOT_ID, 9);
				startActivity(intent);
			}
		});
		ImageButton b4 = (ImageButton) v.findViewById(R.id.imageButton4);
		b4.setOnClickListener(new View.OnClickListener() {
			public void onClick(View view) {
				
				intent.putExtra(DEPOT_ID, 6);
				startActivity(intent);
			}
		});
		ImageButton b6 = (ImageButton) v.findViewById(R.id.imageButton6);
		b6.setOnClickListener(new View.OnClickListener() {
			public void onClick(View view) {
				
				intent.putExtra(DEPOT_ID, 5);
				startActivity(intent);

			}
		});
		ImageButton b7 = (ImageButton) v.findViewById(R.id.imageButton7);
		b7.setOnClickListener(new View.OnClickListener() {
			public void onClick(View view) {
				
				intent.putExtra(DEPOT_ID, 4);
				startActivity(intent);
			}
		});
		ImageButton b8 = (ImageButton) v.findViewById(R.id.imageButton8);
		b8.setOnClickListener(new View.OnClickListener() {
			public void onClick(View view) {
				
				intent.putExtra(DEPOT_ID, 0);
				startActivity(intent);
			}
		});

		ImageButton b9 = (ImageButton) v.findViewById(R.id.imageButton9);
		b9.setOnClickListener(new View.OnClickListener() {
			public void onClick(View view) {
				
				intent.putExtra(DEPOT_ID, 1);
				startActivity(intent);
			}
		});

		ImageButton b10 = (ImageButton) v.findViewById(R.id.imageButton10);
		b10.setOnClickListener(new View.OnClickListener() {
			public void onClick(View view) {
				
				intent.putExtra(DEPOT_ID, 3);
				startActivity(intent);
			}
		});

		ImageButton b11 = (ImageButton) v.findViewById(R.id.imageButton11);
		b11.setOnClickListener(new View.OnClickListener() {
			public void onClick(View view) {
				
				intent.putExtra(DEPOT_ID, 2);
				startActivity(intent);
			}
		});


		return v;
	}
}
